package com.design.pattern.command;

/**
 * Created by Administrator on 2016/5/18.
 * 客户端角色
 */
public class Julia {
    public static void main(String[] args) {
        //1. 创建接受者
        AudioPlayer audioPlayer = new AudioPlayer();
        //2. 创建命令对象
        PlayCommand playCommand = new PlayCommand(audioPlayer);
        RewindCommand rewindCommand = new RewindCommand(audioPlayer);
        StopCommand stopCommand = new StopCommand(audioPlayer);
        //3. 创建请求者
        Keypad keypad = new Keypad();
        keypad.setPlayCommand(playCommand);
        keypad.setRewindCommand(rewindCommand);
        keypad.setStopCommand(stopCommand);

        //4. 通过keypad发送命令
        keypad.play();
        keypad.rewind();
        keypad.play();
        keypad.stop();


    }
}
